﻿using Microsoft.Xna.Framework;
using Rescue_of_the_Dwarvenzombies.Scene.Levels;
using Rescue_of_the_Dwarvenzombies.SceneObjects.GameObjects.Characters.Enemies;
using GameLibrary;

namespace Rescue_of_the_Dwarvenzombies.SceneLayers
{
    public class ObstacleLayer : SceneLayer
    {
        private Game _game;

        /// <summary>
        /// Initializes a new instance of the <see cref="ObstacleLayer"/> class.
        /// </summary>
        /// <param name="game">The game.</param>
        public ObstacleLayer(Game game)
            : base(game)
        {
            _game = game;
            Child = null;
            LayerName = Constant.Layer.Obstacle;
            InitObjects();
            AI.Instance().ObstacleLayer = this;
            Depth = Constant.OBSTACLE_LAYER_DEPTH;
        }

        /// <summary>
        /// Inits the objects.
        /// </summary>
        protected override sealed void InitObjects()
        {
            ILevel level = ((ILevel)_game.Services.GetService(typeof(ILevel)));

            SceneObjects.AddRange(level.GetWalls());
            SceneObjects.AddRange(level.GetStones());
        }
    }
}